<?php
/*
 * Created on 14/12/2008
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */

/*
 * Controller
 */
include_once ("includes/init.php");
$submit = getParam("submit");
$from = stripslashes(getParam("from"));
$subject = stripslashes(getParam("subject"));
$comment = stripslashes(getParam("comment"));
 
$showStats = false;
include_once ("includes/header.php");
if (strlen($from) == 0 &&  isset($loggedin)) {
    $from = $loggedin->email;
}
echo<<< EOQ
    <caption><h1>Contact Us</h1></caption>
	<form method="post">
    <tr>
    	<td>From:</td>
    	<td><input type="text" size="64" maxsize="64" name="from" value="$from"></td>
	</tr>
    <tr>
    	<td>Subject:</td>
    	<td><input type="text" size="64" maxsize="128" name="subject" value="$subject"></td>
	</tr>
    <tr>
    	<td colspan="2"><TEXTAREA name="comment" rows="10" cols="100">$comment</TEXTAREA></td>
	</tr>
    <tr>
    	<td colspan="2" align="center"><input type="submit" name="submit" value="Send Message"></td>
	</tr>
	</form>
	<form>
    <tr>
    	<td colspan="2" align="center"><input type="submit" name="clear" value="Clear Form"></td>
	</tr>
	</form>
EOQ;

if (isset($submit) && strlen($comment) > 0 && strlen($subject) > 0 && strlen($from) > 0) {
	$message = "$from has send you this message through the $leagueNameShort website\n\n" 
	. "***************************************************************************\n\n"
	. "From: $from\n"
	. "Subject: $subject\n"
	. "Message:\n"
	. "$comment";

	$headers = "From: $from\r\n" .
	   "Reply-To: $from\r\n" .
	   "X-Mailer: PHP/" . phpversion();

	mail($MAILTO, $subject, $message, $headers);
echo<<< EOQ
    <tr>
    	<th colspan="2" align="center">Message sent</th>
	</tr>
EOQ;
}

include_once ("includes/footer.php");
?>
